import { createPinia, defineStore } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)

export default pinia

// 示例store，可以根据需要修改或删除
export const useCounterStore = defineStore('counter', {
  state: () => ({
    count: 0
  }),
  actions: {
    // 同步 action
    increment(num = 1) {
      this.count += num // this 指向 state
    }
  },
  persist: true // 启用持久化
})
